package values.enlist
{
	import framework.dao.EntryUtil;
	
	import values.avatar.AvatarTemplateValue;
	import values.avatar.AvatarTemplateValueList;
	import values.common.CostValue;

	public class EnlistTemplateValue
	{
		[Data(type="field" , mapping="@key")]
		public var key:String;
		
		[Data(type="field" , mapping="@avatar_key")]
		public var avatarKey:String;
		
		[Data(type="field" , mapping="@reputation")]
		public var reputation:int;
		
		public function get avatarTemplate():AvatarTemplateValue
		{
			return AvatarTemplateValueList.getByKey(avatarKey);
		}
		
		[Data(type="field",  mapping="cost")]
		public var baseCostDef:*;
		
		protected var _cost:CostValue;
		
		public function get cost():CostValue
		{
			if (!_cost)
			{
				_cost = EntryUtil.mapping(baseCostDef, CostValue);
				_cost.owner = this;
			}
			return _cost;
		}
		
	}
}